package game.sb;

import com.bit.catmoney.GameServer;
import com.bit.catmoney.MainActivity;
import com.bit.catmoney.OptActivity;
import com.bit.catmoney.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

public class ScoreActivity extends Activity implements OnClickListener{

	ImageButton btn1;
	ImageButton btn2;
	private Activity activity;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_score);
		
		
		Intent intent = getIntent();
		String strScore = intent.getStringExtra("Score");
		
		TextView txtScore = (TextView)findViewById(R.id.txt1);
		txtScore.setText(strScore);
		
		SharedPreferences prefs = getSharedPreferences("PrefName", MODE_PRIVATE);
		String txtid = prefs.getString(PrefActivity.KEY_MY_PREFERENCE, "");
		
		GameServer server = new GameServer();
		server.sendScore(txtid, strScore, null);
		
		btn1 = (ImageButton)findViewById(R.id.main_btn);
		btn1.setOnClickListener(this);
		
		btn2 = (ImageButton)findViewById(R.id.again_btn);
		btn2.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.main_btn:
			Intent intent = new Intent(ScoreActivity.this, MainActivity.class);
			intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent);
			finish();
			break;
		case R.id.again_btn:
			Intent intent1 = new Intent(ScoreActivity.this, CatMoney.class);
			startActivity(intent1);
			break;
		default:
			break;
		}
	}
	public void onBackPressed(){
		Intent intent = new Intent(ScoreActivity.this, MainActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivity(intent);
		finish();
	}
}
